<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>轮回之牢: D:/Code/cProgram/CPP/Qt/TeamCurriculumDesign/Item/Bag/BaseBag.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">轮回之牢<span id="projectnumber">&#160;0.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_80876d1476b72d92a9650b7ee3516e4c.html">TeamCurriculumDesign</a></li><li class="navelem"><a class="el" href="dir_7b149e5ebf6d24756f03bb71c9a9b2ab.html">Item</a></li><li class="navelem"><a class="el" href="dir_1b672381577305208bc12dfc0be180cf.html">Bag</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">BaseBag.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">//</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment">// Created by lenovo on 2021/9/3.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment">//</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span> </div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="preprocessor">#ifndef TEAMCURRICULUMDESIGN_BASEBAG_H</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="preprocessor">#define TEAMCURRICULUMDESIGN_BASEBAG_H</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="preprocessor">#include &quot;../BaseItem.h&quot;</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;../../Scenes/Objects/DropObject.h&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"><a class="line" href="class_base_bag.html">   15</a></span><span class="keyword">class </span><a class="code hl_class" href="class_base_bag.html">BaseBag</a> {</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="keyword">protected</span>:</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"><a class="line" href="class_base_bag.html#a27dc71924115f9284cf64cc032c2f93c">   20</a></span>    std::map&lt;int, BaseItem *&gt; <a class="code hl_variable" href="class_base_bag.html#a27dc71924115f9284cf64cc032c2f93c">items</a>;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="class_base_bag.html#aea3001595075da8c4defb45ab097bc2d">   24</a></span>    <span class="keywordtype">int</span> <a class="code hl_variable" href="class_base_bag.html#aea3001595075da8c4defb45ab097bc2d">bag_size</a>;</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="class_base_bag.html#afaaac1e5e162510ab3d25c9a8c0de3c1">   28</a></span>    <span class="keywordtype">bool</span> <a class="code hl_variable" href="class_base_bag.html#afaaac1e5e162510ab3d25c9a8c0de3c1">infinite_size</a> = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    <span class="keywordtype">int</span> <a class="code hl_function" href="class_base_bag.html#a277bde808d4e1f921ca8c5cc71255d86">getBagSize</a>() <span class="keyword">const</span>;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="class_base_bag.html#a4cbdaa521e82519640cbb62cfeb55786">empty</a>() <span class="keyword">const</span>;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    std::map&lt;int, BaseItem *&gt;::const_iterator <a class="code hl_function" href="class_base_bag.html#ab6f593bd54b79f960ebfc3994e95f957">begin</a>()<span class="keyword">const</span>;</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>    std::map&lt;int, BaseItem *&gt;::const_iterator <a class="code hl_function" href="class_base_bag.html#ac4a165434591a83c9c610c79d7bbe6be">end</a>()<span class="keyword">const</span>;</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span> </div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span><span class="keyword">protected</span>:</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"><a class="line" href="class_base_bag.html#a432ec09167d998913960f2ae59c59422">   57</a></span>    <span class="keywordtype">int</span> <a class="code hl_variable" href="class_base_bag.html#a432ec09167d998913960f2ae59c59422">item_index</a> = 0;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="class_base_bag.html#a87bb57c8aab2d24dfb07f8c0e225eaea">swapItem</a>(<a class="code hl_class" href="class_base_bag.html">BaseBag</a> *bag1, <a class="code hl_class" href="class_base_bag.html">BaseBag</a> *bag2);</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>    <span class="keyword">explicit</span> <a class="code hl_function" href="class_base_bag.html#ad5f96f0a0b99c9c8dca416e4d54e5ec0">BaseBag</a>(<span class="keywordtype">int</span> bagSize, <span class="keywordtype">bool</span> <a class="code hl_variable" href="class_base_bag.html#afaaac1e5e162510ab3d25c9a8c0de3c1">infinite_size</a> = <span class="keyword">false</span>);</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="class_base_bag.html#a3dcd7ede0d822471bccc6550688c0d74">inputItem</a>(<a class="code hl_class" href="class_base_item.html">BaseItem</a> *item);</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="class_base_bag.html#a179deee9049854bd7a8e108ca3e2f3dd">outputItem</a>(<span class="keyword">const</span> <a class="code hl_class" href="class_point.html">Point</a> &amp;drop_pos, <a class="code hl_class" href="class_drop_object.html">DropObject</a> **drop_object_star);</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span> </div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="class_base_bag.html#a179deee9049854bd7a8e108ca3e2f3dd">outputItem</a>(<a class="code hl_class" href="class_base_item.html">BaseItem</a> **drop_object_star);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span> </div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="class_base_bag.html#ab95f67e853a800ffd8afa953c002f909">draw</a>(<span class="keywordtype">float</span> window_width, <span class="keywordtype">float</span> window_height) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span> </div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>    <a class="code hl_class" href="class_base_item.html">BaseItem</a> *<a class="code hl_function" href="class_base_bag.html#a63b46cc31fb2c6029a8643dc78126d82">operator[]</a>(<span class="keywordtype">int</span> index);</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span> </div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>    <span class="keywordtype">int</span> <a class="code hl_function" href="class_base_bag.html#adce0190c906b6d9f59bcd0d3d5d8b5bd">getItemIndex</a>() <span class="keyword">const</span>;</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span> </div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_base_bag.html#a2490bc1b4b60b9e1aa997b3d8efaff1d">setItemIndex</a>(<span class="keywordtype">int</span> itemIndex);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span> </div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>    <span class="keyword">virtual</span> <a class="code hl_class" href="class_base_bag.html">~BaseBag</a>();</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span> </div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="class_base_bag.html#a602a4d3f0bd9a9f5e010d4ed13c00afd">canInputItem</a>(<a class="code hl_class" href="class_base_item.html">BaseItem</a> *baseItem);</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span> </div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="class_base_bag.html#ad1ab953e57727217c20aa5fb6d851c20">normalRefresh</a>();</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>};</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span> </div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span> </div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span><span class="preprocessor">#endif </span><span class="comment">//TEAMCURRICULUMDESIGN_BASEBAG_H</span></div>
<div class="ttc" id="aclass_base_bag_html"><div class="ttname"><a href="class_base_bag.html">BaseBag</a></div><div class="ttdoc">背包基类</div><div class="ttdef"><b>Definition:</b> BaseBag.h:15</div></div>
<div class="ttc" id="aclass_base_bag_html_a179deee9049854bd7a8e108ca3e2f3dd"><div class="ttname"><a href="class_base_bag.html#a179deee9049854bd7a8e108ca3e2f3dd">BaseBag::outputItem</a></div><div class="ttdeci">virtual bool outputItem(const Point &amp;drop_pos, DropObject **drop_object_star)</div><div class="ttdoc">从背包丢出东西 返回是否丢弃成功</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:47</div></div>
<div class="ttc" id="aclass_base_bag_html_a2490bc1b4b60b9e1aa997b3d8efaff1d"><div class="ttname"><a href="class_base_bag.html#a2490bc1b4b60b9e1aa997b3d8efaff1d">BaseBag::setItemIndex</a></div><div class="ttdeci">void setItemIndex(int itemIndex)</div><div class="ttdoc">设置当前物品索引</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:130</div></div>
<div class="ttc" id="aclass_base_bag_html_a277bde808d4e1f921ca8c5cc71255d86"><div class="ttname"><a href="class_base_bag.html#a277bde808d4e1f921ca8c5cc71255d86">BaseBag::getBagSize</a></div><div class="ttdeci">int getBagSize() const</div><div class="ttdoc">获取背包容量，在背包无限容量时可能获取到任意值</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:134</div></div>
<div class="ttc" id="aclass_base_bag_html_a27dc71924115f9284cf64cc032c2f93c"><div class="ttname"><a href="class_base_bag.html#a27dc71924115f9284cf64cc032c2f93c">BaseBag::items</a></div><div class="ttdeci">std::map&lt; int, BaseItem * &gt; items</div><div class="ttdoc">背包内的物品</div><div class="ttdef"><b>Definition:</b> BaseBag.h:20</div></div>
<div class="ttc" id="aclass_base_bag_html_a3dcd7ede0d822471bccc6550688c0d74"><div class="ttname"><a href="class_base_bag.html#a3dcd7ede0d822471bccc6550688c0d74">BaseBag::inputItem</a></div><div class="ttdeci">virtual bool inputItem(BaseItem *item)</div><div class="ttdoc">向背包内放入东西，返回是否放入成功</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:16</div></div>
<div class="ttc" id="aclass_base_bag_html_a432ec09167d998913960f2ae59c59422"><div class="ttname"><a href="class_base_bag.html#a432ec09167d998913960f2ae59c59422">BaseBag::item_index</a></div><div class="ttdeci">int item_index</div><div class="ttdoc">当前物品的索引值</div><div class="ttdef"><b>Definition:</b> BaseBag.h:57</div></div>
<div class="ttc" id="aclass_base_bag_html_a4cbdaa521e82519640cbb62cfeb55786"><div class="ttname"><a href="class_base_bag.html#a4cbdaa521e82519640cbb62cfeb55786">BaseBag::empty</a></div><div class="ttdeci">bool empty() const</div><div class="ttdoc">获取背包是否为空</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:184</div></div>
<div class="ttc" id="aclass_base_bag_html_a602a4d3f0bd9a9f5e010d4ed13c00afd"><div class="ttname"><a href="class_base_bag.html#a602a4d3f0bd9a9f5e010d4ed13c00afd">BaseBag::canInputItem</a></div><div class="ttdeci">virtual bool canInputItem(BaseItem *baseItem)</div><div class="ttdoc">用于检测物体与背包的兼容性，限制物品类型的背包必须实现 不检查背包剩余容量</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:180</div></div>
<div class="ttc" id="aclass_base_bag_html_a63b46cc31fb2c6029a8643dc78126d82"><div class="ttname"><a href="class_base_bag.html#a63b46cc31fb2c6029a8643dc78126d82">BaseBag::operator[]</a></div><div class="ttdeci">BaseItem * operator[](int index)</div><div class="ttdoc">取背包内对应下标的物品</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:118</div></div>
<div class="ttc" id="aclass_base_bag_html_a87bb57c8aab2d24dfb07f8c0e225eaea"><div class="ttname"><a href="class_base_bag.html#a87bb57c8aab2d24dfb07f8c0e225eaea">BaseBag::swapItem</a></div><div class="ttdeci">static void swapItem(BaseBag *bag1, BaseBag *bag2)</div><div class="ttdoc">尝试交换两个背包内的物品，可能失败</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:148</div></div>
<div class="ttc" id="aclass_base_bag_html_ab6f593bd54b79f960ebfc3994e95f957"><div class="ttname"><a href="class_base_bag.html#ab6f593bd54b79f960ebfc3994e95f957">BaseBag::begin</a></div><div class="ttdeci">std::map&lt; int, BaseItem * &gt;::const_iterator begin() const</div><div class="ttdoc">遍历背包的迭代器起点</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:188</div></div>
<div class="ttc" id="aclass_base_bag_html_ab95f67e853a800ffd8afa953c002f909"><div class="ttname"><a href="class_base_bag.html#ab95f67e853a800ffd8afa953c002f909">BaseBag::draw</a></div><div class="ttdeci">virtual void draw(float window_width, float window_height) const</div><div class="ttdoc">用于前端的绘制函数</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:60</div></div>
<div class="ttc" id="aclass_base_bag_html_ac4a165434591a83c9c610c79d7bbe6be"><div class="ttname"><a href="class_base_bag.html#ac4a165434591a83c9c610c79d7bbe6be">BaseBag::end</a></div><div class="ttdeci">std::map&lt; int, BaseItem * &gt;::const_iterator end() const</div><div class="ttdoc">遍历背包的迭代器终点</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:192</div></div>
<div class="ttc" id="aclass_base_bag_html_ad1ab953e57727217c20aa5fb6d851c20"><div class="ttname"><a href="class_base_bag.html#ad1ab953e57727217c20aa5fb6d851c20">BaseBag::normalRefresh</a></div><div class="ttdeci">virtual void normalRefresh()</div><div class="ttdoc">每帧刷新是调用，可以在此进行可消耗物品的刷新</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:196</div></div>
<div class="ttc" id="aclass_base_bag_html_ad5f96f0a0b99c9c8dca416e4d54e5ec0"><div class="ttname"><a href="class_base_bag.html#ad5f96f0a0b99c9c8dca416e4d54e5ec0">BaseBag::BaseBag</a></div><div class="ttdeci">BaseBag(int bagSize, bool infinite_size=false)</div><div class="ttdoc">构造函数</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:12</div></div>
<div class="ttc" id="aclass_base_bag_html_adce0190c906b6d9f59bcd0d3d5d8b5bd"><div class="ttname"><a href="class_base_bag.html#adce0190c906b6d9f59bcd0d3d5d8b5bd">BaseBag::getItemIndex</a></div><div class="ttdeci">int getItemIndex() const</div><div class="ttdoc">获取当前物品索引</div><div class="ttdef"><b>Definition:</b> BaseBag.cpp:126</div></div>
<div class="ttc" id="aclass_base_bag_html_aea3001595075da8c4defb45ab097bc2d"><div class="ttname"><a href="class_base_bag.html#aea3001595075da8c4defb45ab097bc2d">BaseBag::bag_size</a></div><div class="ttdeci">int bag_size</div><div class="ttdoc">背包大小，仅在背包容量有限时触发</div><div class="ttdef"><b>Definition:</b> BaseBag.h:24</div></div>
<div class="ttc" id="aclass_base_bag_html_afaaac1e5e162510ab3d25c9a8c0de3c1"><div class="ttname"><a href="class_base_bag.html#afaaac1e5e162510ab3d25c9a8c0de3c1">BaseBag::infinite_size</a></div><div class="ttdeci">bool infinite_size</div><div class="ttdoc">背包是否无限，默认否</div><div class="ttdef"><b>Definition:</b> BaseBag.h:28</div></div>
<div class="ttc" id="aclass_base_item_html"><div class="ttname"><a href="class_base_item.html">BaseItem</a></div><div class="ttdoc">物品基类</div><div class="ttdef"><b>Definition:</b> BaseItem.h:13</div></div>
<div class="ttc" id="aclass_drop_object_html"><div class="ttname"><a href="class_drop_object.html">DropObject</a></div><div class="ttdoc">掉落物</div><div class="ttdef"><b>Definition:</b> DropObject.h:12</div></div>
<div class="ttc" id="aclass_point_html"><div class="ttname"><a href="class_point.html">Point</a></div><div class="ttdoc">二维点</div><div class="ttdef"><b>Definition:</b> Point.h:18</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
